package com.example.work.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.work.entity.DbCheckCategory;
import com.example.work.mapper.DbCheckCategoryMapper;
import com.example.work.service.ICategoryService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**

 */
@Service("categoryService")
public class ICategoryServiceImpl extends ServiceImpl<DbCheckCategoryMapper, DbCheckCategory> implements ICategoryService {

    @Autowired
    private DbCheckCategoryMapper dbCheckCategoryMapper;
    @Override
    public boolean updateCategoryById(DbCheckCategory dbCheckCategory) {
        // 调用 BaseMapper 的 updateById 方法
        return this.updateById(dbCheckCategory);
    }
    @Override
    public List<Map<String, Object>> getActiveCategories() {
        // 构造查询条件：deleteFlag = 0
        QueryWrapper<DbCheckCategory> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("delete_flag", 1).select("id", "name"); // 只查询 id 和 name 字段

        // 查询结果返回 Map 列表
        return dbCheckCategoryMapper.selectMaps(queryWrapper);
    }
}
